﻿using System.Collections.Generic;
using System.Linq;
using System.Windows;
using Microsoft.Windows.Controls;

namespace WDCF
{
    /// <summary>
    /// DataGrid Row Formatter
    /// </summary>
    public class DataGridConditionalRowFormatter : DataGridConditionalFormatter
    {
        public DataGridConditionalRowFormatter(
            DataGrid dataGrid,
            IList<Condition> conditions)
            :base(dataGrid, conditions)
        {
        }

        #region Overrides of DataGridConditionalFormatter

        /// <summary>
        /// Generates a <see cref="Style"/> object and applies it to the grid.
        /// Target is <see cref="DataGridRow"/>.
        /// </summary>
        public override void Apply()
        {
            var style = GetStyle<DataGridRow>();

            if (style != null)
            {
                Grid.RowStyle = style;
            }
        }

        /// <summary>
        /// Gets the <see cref="Style"/> object which shall be replaced with
        /// conditional formatting. Gets the <see cref="DataGrid.RowStyle"/> of the grid.
        /// </summary>
        protected override Style TargetStyle
        {
            get { return Grid.RowStyle; }
        }

        #endregion
    }
}
